home *** CD-ROM | disk | FTP | other *** search
- {****************************************************}
- { CPaintTask.p}
- {}
- { The PaintTask Class}
- {}
- { SUPERCLASS = CMouseTask}
- {}
- { Copyright ⌐ 1989, Symantec Corporation. All rights reserved. }
- {}
- {****************************************************}
-
- unit CPaintTask;
-
- interface
-
- uses
- TCL, MoreTCL, ArtClassIntf;
-
- implementation
-
-
-
- {*** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ***}
-
-
-
- {****************************************************}
- { IPaintTask}
- {}
- { Initialize a PaintTask object}
- {}
- {****************************************************}
-
- procedure CPaintTask.IPaintTask (aNameIndex: integer; aPaintPane: CPaintPane; aPainting: CBitMap);
- begin
- inherited IMouseTask(aNameIndex);
-
- itsPaintPane := aPaintPane;
- itsPainting := aPainting;
- itsUndoBits := nil;
- end;
-
-
- {****************************************************}
- { Free (OVERRIDE)}
- {}
- { Dispose of a PaintTask object}
- {}
- {****************************************************}
-
- procedure CPaintTask.Free;
- begin
- if itsUndoBits <> nil then
- itsUndoBits.Free;
-
- inherited Free; { Pass message on to superclass }
- end;
-
-
- {****************************************************}
- { Undo (OVERRIDE)}
- {}
- { Undo an action performed by a paint task}
- {}
- {****************************************************}
-
- procedure CPaintTask.Undo;
- var
- bounds: Rect;
- begin
- if itsUndoBits <> nil then
- begin
- itsUndoBits.GetBounds(bounds);
-
- CopyBits(itsPainting.macBitMap, gScratchPad.macBitMap, bounds, bounds, srcCopy, nil);
-
- CopyBits(itsUndoBits.macBitMap, itsPainting.macBitMap, bounds, bounds, srcCopy, nil);
-
- CopyBits(gScratchPad.macBitMap, itsUndoBits.macBitMap, bounds, bounds, srcCopy, nil);
-
- itsPaintPane.Prepare;
- itsPainting.CopyFrom(bounds, bounds, nil);
- end;
- end;
-
-
- {****************************************************}
- { SaveForUndo}
- {}
- { Save an area of the Painting so a change can be undone}
- {}
- {****************************************************}
-
- procedure CPaintTask.SaveForUndo (undoRect: Rect);
- var
- theUndoBits: CBitMap; { Altered by TCL Weaver 1.0 (5/9/90) }
-
- begin
- { Put changed area of painting into }
- { an undo bitmap }
-
- new(theUndoBits); { Altered by TCL Weaver 1.0 (5/9/90) }
- itsUndoBits := theUndoBits;
- gApplication.RequestMemory(TRUE, TRUE);
- itsUndoBits.IBitMap(undoRect.right - undoRect.left, undoRect.bottom - undoRect.top, FALSE);
- gApplication.RequestMemory(FALSE, FALSE);
-
- if itsUndoBits.macBitMap.baseAddr = nil then
- begin
- itsUndoBits.Free;
- itsUndoBits := nil;
-
- end
- else
- begin
- itsUndoBits.SetBoundsOrigin(undoRect.left, undoRect.top);
-
- CopyBits(itsPainting.macBitMap, itsUndoBits.macBitMap, undoRect, undoRect, srcCopy, nil);
- end;
- end;
-
-
- end.